from django.utils.deprecation import MiddlewareMixin

from web import models


class AuthMiddlewares(MiddlewareMixin):
    def process_request(self,request):
        '''如果用户已登录，则在request中赋值'''
        user_id=request.session.get('user_id',0)
        user_objects=models.WebUser.objects.filter(id=user_id).first()
        request.sxj=user_objects